<?php

// $Id$


require_once(TANGRA_MAIN_DIR.'web_site/session_vars_manager.class.php');
require_once(TANGRA_MAIN_DIR.'exceptions/te_session_not_started.class.php');
require_once(TANGRA_MAIN_DIR.'exceptions/te_session_vars_manager_overwrited.class.php');


require_once($WSC->get_site_inc_dir().'modules/web_site_vanilla/web_site_vanilla.class.php');


class Web_Site_Strawberry extends Web_Site_Vanilla {
	public function init() {
		parent::init();
		$this->init_session();
	}


	private function init_session() {
		$context = $this->get__context();

		$svm_var_name = Session_Vars_Manager::get_svm_var_name();

		if (isset($_SESSION)) {
			if ($context->exists_in_session($svm_var_name)) {
				$sm = $this->get_svm($context);
				if (!($sm instanceof Session_Vars_Manager)) {
					throw new TE_Session_Vars_Manager_Overwrited();
				}
			} else {
				$session = &$context->get_var('SESSION');
				$session[$svm_var_name] = new Session_Vars_Manager();
			}
		} else {
			throw new TE_Session_Not_Started();
		}
	}


	public function get_svm() {
		$context = $this->get__context();

		$svm_var_name = Session_Vars_Manager::get_svm_var_name();
		$svm = $context->get_from_session($svm_var_name);

		return $svm;
	}
}



